package streaming.test.working;

import javax.media.DataSink;
import javax.media.Format;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Processor;
import javax.media.ProcessorModel;
import javax.media.format.AudioFormat;
import javax.media.format.VideoFormat;
import javax.media.protocol.ContentDescriptor;

import com.sun.media.sdp.MediaDescription;

public class RealizedProcessorAndDataSinkTransmit {

	
	Processor processor, audioProcessor;
	AudioFormat RTPformatA = new AudioFormat(AudioFormat.GSM_RTP);
	VideoFormat RTPformat = new VideoFormat(VideoFormat.JPEG_RTP);
	AudioFormat formatA = new AudioFormat(AudioFormat.LINEAR, 8000, 8, 1);
	VideoFormat format = new VideoFormat(VideoFormat.RGB);
	
	MediaLocator mediaLocator = new MediaLocator("rtp://192.168.13.255:22222:1/video");
	MediaLocator mediaAudioLocator = new MediaLocator("rtp://192.168.13.255:22222:2/audio");
	
	
	
	ContentDescriptor outputContentDescriptor = new ContentDescriptor(ContentDescriptor.RAW_RTP);
	
	
	private void initializeProcessor() throws Exception{
		processor = Manager.createRealizedProcessor(new ProcessorModel(new Format[]{RTPformat}, outputContentDescriptor));
	
		audioProcessor = Manager.createRealizedProcessor(new ProcessorModel(new Format[]{RTPformatA}, outputContentDescriptor));
		
		
		
		DataSink sendingSink = Manager.createDataSink(processor.getDataOutput(), mediaLocator);
	
		DataSink sendingAudioSink = Manager.createDataSink(audioProcessor.getDataOutput(), mediaAudioLocator);
		
		processor.start();
		audioProcessor.start();
		
		
		sendingSink.open();
		sendingSink.start();
		

		sendingAudioSink.open();
		sendingAudioSink.start();
	}
	
	public static void main(String[] args) throws Exception {
		new RealizedProcessorAndDataSinkTransmit().initializeProcessor();
	}
}
